package m202403.d12;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/3/12 15:34
 */
//509. 斐波那契数
public class Q509 {
    public int fib(int n) {
        if (n < 2) {
            return n;
        }
        int r0 = 0;
        int r1 = 1;
        int r = 0;
        for (int i = 2; i <= n; i++) {
            r = r0 + r1;
            r0 = r1;
            r1 = r;
        }
        return r;
    }
}
